import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Login from '@/container/Login'
import Register from '@/container/Register'
import Boss from '@/container/Boss'

Vue.use(Router)

//获取用户信息
// const publicList = ['/login', '/register']
// const pathName = this.$router.currentRoute.path;
//
// Router.beforeEach((to, from, next) => {
// 	if (publicList.indexOf(pathName) > -1) {
// 		return null
// 	}
// 	this.$http('/api/user/info').then(res => {
// 		if (res.status == 200) {
// 			if (res.data.code == 0) {
// 				有登录信息
// 			} else {
// 				console.log();
// 				this.$router.push('login')
// 			}
// 		}
// 		console.log(res.data)
// 		alert(1)
//
// 	})
// 	next()
//
// })
export default new Router({
	routes: [
		{
			path: '/',
			name: 'HelloWorld',
			component: HelloWorld
		}, {
			path: '/login',
			name: 'Login',
			component: Login
		}, {
			path: '/register',
			name: 'Register',
			component: Register
		}, {
			path: '/boss',
			name: 'boss',
			component: Boss
		}
	]
})
